package com.ericsson.enap.modules.ossalarm.task.vgc;

import com.ericsson.common.quartz.task.ManualTask;
import org.springframework.stereotype.Component;

import java.io.BufferedReader;
import java.io.InputStreamReader;

@Component
public class VgcEnmAlarmMonitorTask implements ManualTask {
    @Override
    public void execute() {
        Process process = null;
        String command[] = new String[3];
        command[0] = "sh";
        command[1] = "-c";
        command[2] = "/opt/Ericsson/core/bin/monitor.sh";
        try {
            process = Runtime.getRuntime().exec(command);
            BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
            String line = null;
            while((line = br.readLine())!=null){
                System.out.println("==========:"+line);
            }
            br.close();
            process.waitFor();
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            process.destroy();
        }
    }
}
